<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Server room temperature monitor</title>
</head>
<body>
<?php
$myConfigFile = "/var/www/temperature/temperature.dat";
  $email 	= $_REQUEST['email'] ;
  $message	= $_REQUEST['message'] ;
  $subject 	= $_REQUEST['subject'] ;
  $max_temp 	= $_REQUEST['max_temp'] ;
  $min_temp 	= $_REQUEST['min_temp'] ;
  $password 	= $_REQUEST['password'] ;
  $submit	= $_REQUEST['submit'] ;
if ($submit == "submit" && isset($email) && isset($message) && isset($subject) && isset($max_temp) && isset($min_temp) && $password == "entomeo6") {
$fh = fopen($myConfigFile, 'w') or die("can't open file");
$stringData = $email . "\n" . $subject . "\n" . $message . "\n" . $max_temp . "\n" . $min_temp . "\n";
fwrite($fh, $stringData);
fclose($fh);
echo "Saved<br>";
}

$myFile = "/var/www/temperature/temperature";
$fh = fopen($myFile, 'r') or die("can't open file");
$theData = fread($fh, filesize($myFile));
fclose($fh);
$temp = explode ("\n", $theData);
echo "Current temperature: " . $temp[0] . " oC<br>";

$myFile = "/var/www/temperature/temperature.lastalarm";
$fh = fopen($myFile, 'r') or die("can't open file");
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo "Last alarm occured: " . date("d-m-y H:i:s",$theData);
echo "<br>";

$fh = fopen($myConfigFile, 'r') or die("can't open file");
$theData = fread($fh, filesize($myConfigFile));
fclose($fh);
$confdata = explode ("\n", $theData);
?>
<form enctype="application/x-www-form-urlencoded" action="temperature.php" method="post"><dl class="zend_form">
<dt><label for="email" class="required">email:</label></dt>
<dd>
<input type="text" name="email" id="email" value="<?=$confdata[0]?>"></dd>
<dt><label for="subject" class="required">email subject:</label></dt>
<dd>
<input type="text" name="subject" id="subject" value="<?=$confdata[1]?>"></dd>
<dt><label for="message" class="required">email message:</label></dt>
<dd>
<input type="text" name="message" id="message" value="<?=$confdata[2]?>"></dd>
<dt><label for="max_temp" class="required">max temp value:</label></dt>
<dd>
<input type="text" name="max_temp" id="max_temp" value="<?=$confdata[3]?>"></dd>
<dt><label for="min_temp" class="required">min temp value:</label></dt>
<dd>
<input type="text" name="min_temp" id="max_temp" value="<?=$confdata[4]?>"></dd>
<dt><label for="password" class="required">password</label></dt>
<dd>
<input type="password" name="password" id="password" value=""></dd>
<dt>&nbsp;</dt><dd>
<input type="submit" name="submit" id="submit" value="submit"></dd></dl></form>
</body>
</html>